1. Field of the Invention
The present invention generally relates to a multiplier algorithm for correcting signals and a circuit thereof, in particular, to a combined multiplier algorithm and a circuit thereof which can output corrected signals, and an image correcting method and a circuit thereof using the same.
2. Description of Related Art
In the processing of digital image signals, a multiplier is usually adopted in an image processing integrated circuit (IC) for executing signal multiplication. For example, in the image processing IC of a digital camera, several image signal processing procedures are usually performed to a digital image signal, as shown in FIG. 1.
FIG. 1 illustrates the processing procedures in an image processing IC. In the digital camera, first, an analog signal output by the image sensor is converted into digital red, green, and blue (RGB) signals by the analog/digital converter of the sensor analog front end, and then the signals are processed by the image processing IC. Referring to FIG. 1, the image processing IC performs such processes as the white balance gain correction 102, the inverse optical electronic conversion function 104, the color filter array interpolation 106, the color correction 108, the color space transform 110, and the gamma correction 112 to obtain a desired image signal Im, wherein the color space transform 110 is to convert the RGB signals into a luminance signal Y and two chroma signals Cb, Cr.
Generally speaking, the processes performed and the order in which they are performed may differ according to different algorithms. However, a multiplier has to be used in foregoing white balance gain correction 102, color correction 108, or color space transform 110. To reduce the cost of an image processing IC, the multipliers in different processes are usually combined. For example, the multipliers used in the white balance gain correction 102 and the color correction 108 are combined, as shown in FIG. 2, or the multipliers used in the color correction 108 and the color space transform 110 are combined, as shown in FIG. 3, or even the multipliers used in the white balance gain correction 102, the color correction 108, and the color space transform 110 are all combined, as shown in FIG. 4. FIGS. 2˜4 are diagrams illustrating the combinations of multipliers in various processes.
However, problems may be caused if the multipliers in different processes are simply combined without any additional process, wherein the main problem is that when an out-of-domain value (illegal value) is input into the entire calculation formula, the calculated result will overflow, namely, an incorrect result will be obtained. From our observation, such incorrect results may cause abnormal colors in the high luminance regions of an image, and accordingly reduce the quality of the entire image. This situation will be described in detail below.
FIG. 5 illustrates a general multiplication circuit. In the general multiplication circuit, a multiplier 502 performs a multiplication on an input signal IN and another signal A, and an output clamp circuit 504 clamps the domain of the output result OUT. The output clamp circuit 504 usually has a fixed maximum clamp value in accordance with the bit number of the output result OUT. For example, the maximum clamp value is 255 if the output result OUT has 8 bits, and the maximum clamp value is 1023 if the output result OUT has 10 bits. However, unexpected value will be produced if the multipliers are combined and the original multiplication circuit in FIG. 5 is adopted without making any corresponding correction.
An example will be explained below, wherein the output result has 8 bits and the white balance gain correction and color correction are performed. If the white balance gain correction is performed when the multipliers in foregoing two processes are not combined, the output is expressed as:
                                          [                                                            R                                                                              G                                                                              B                                                      ]                                o            ⁢                                                  ⁢            1                          =                              [                                                                                R                    gain                                                                    0                                                  0                                                                              0                                                                      G                    gain                                                                    0                                                                              0                                                  0                                                                      B                    gain                                                                        ]                    ×                                    [                                                                    R                                                                                        G                                                                                        B                                                              ]                        i                                              (        1        )            Assuming (Ri, Gi, Bi)=(230, 240, 190) and the R signal gain coefficient Rgain, the G signal gain coefficient Ggain, and the B signal gain coefficient Bgain in the white balance gain correcting matrix are respectively 1.5, 1, and 1.25, the output value of the white balance gain correcting process is: (Ro1, Go1, Bo1)=(345, 240, 237.5). Then, the domain of the output value is clamped by the output clamp circuit to obtain: (Ro1, Go1, Bo1)=(255, 240, 237.5). Next, color correction is performed to the value (255, 240, 237.5):
                                          [                                                            R                                                                              G                                                                              B                                                      ]                                o            ⁢                                                  ⁢            2                          =                              [                                                            rr                                                  rg                                                  rb                                                                              gr                                                  gg                                                  gb                                                                              br                                                  bg                                                  bb                                                      ]                    ×                                    [                                                                    R                                                                                        G                                                                                        B                                                              ]                                      o              ⁢                                                          ⁢              1                                                          (        2        )            with following color correcting coefficients:
                              [                                                    rr                                            rg                                            rb                                                                    gr                                            gg                                            gb                                                                    br                                            bg                                            bb                                              ]                =                  [                                                    1.3                                                              -                  0.2                                                                              -                  0.1                                                                                    0.1                                            1.4                                                              -                  0.5                                                                                                      -                  0.2                                                                              -                  0.3                                                            1.5                                              ]                                    (        3        )            to obtain: (Ro2, Go2, Bo2)=(259.75, 242.75, 233.75). Thereafter, the domain of the output value is again clamped by the output clamp circuit to obtain a normal output value: (Ro2, Go2, Bo2)=(255, 242.75, 233.75).
However, if the multipliers in the white balance gain correction and color correcting processes are directly combined, the combined matrix is:
                                          [                                                            R                                                                              G                                                                              B                                                      ]                                o            ⁢                                                  ⁢            2                          =                              [                                                            rr                                                  rg                                                  rb                                                                              gr                                                  gg                                                  gb                                                                              br                                                  bg                                                  bb                                                      ]                    ×                      [                                                                                R                    gain                                                                    0                                                  0                                                                              0                                                                      G                    gain                                                                    0                                                                              0                                                  0                                                                      B                    gain                                                                        ]                    ×                                    [                                                                    R                                                                                        G                                                                                        B                                                              ]                        i                                              (        4        )                        wherein                                                                            [                                                            rr                                                  rg                                                  rb                                                                              gr                                                  gg                                                  gb                                                                              br                                                  bg                                                  bb                                                      ]                    ×                      [                                                                                R                    gain                                                                    0                                                  0                                                                              0                                                                      G                    gain                                                                    0                                                                              0                                                  0                                                                      B                    gain                                                                        ]                          =                  [                                                    1.95                                                              -                  0.2                                                                              -                  0.125                                                                                    0.15                                            1.4                                                              -                  0.625                                                                                                      -                  0.3                                                                              -                  0.3                                                            1.875                                              ]                                    (        5        )            FIG. 6 is a circuit diagram of the conventional hardware implementation of a combined multiplier, wherein the image correcting coefficients are as shown in the matrix of equation (5). Referring to FIG. 6, the conventional combined multiplier includes a plurality of multipliers, adders, and output clamp circuits. For example, in FIG. 6, 602 represents a multiplier, 604 represents an adder, and 606 represents an output clamp circuit. Assuming the input signal (Ri, Gi, Bi) is still (230, 240, 190), then the result of equation (5) is (376.75, 251.75, 215.25), and after that, the domain of the result is clamped by the output clamp circuit to obtain (Ro2, Go2, Bo2)=(255, 251.75, 215.25). However, this output result is incorrect, and the correct output result should be (255, 242.75, 233.75).
Similarly, if the input signal (Ri, Gi, Bi) is high luminance such as (255, 255, 255), then the result of equation (5) is (414.375, 235.875, 325.125), and after that, the domain of the result is clamped by the output clamped circuit to obtain (Ro2, Go2, Bo2)=(255, 235.875, 255). However, this output result makes the actual image purplish. Thus, the value (255, 235.875, 255) is incorrect, and the correct value should be (255, 255, 255).
Accordingly, how to output correct values and accordingly ensure correct image color with combined multiplier to reduce hardware cost is needed to be resolved.